<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
                <router-link :to="'/home/newsinfo/' + item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <div class="newslist_tit">
                            <h3>{{ item.title }}</h3>
                            <span>{{ item.add_time | dateFormat }}</span>
                        </div>
                        <p class='mui-ellipsis'>{{ item.zhaiyao }}</p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
import { Toast } from "mint-ui"

export default {
    data(){
        return {
            newslist:[]     // 新闻资讯列表
        }
    },
    created(){
        this.getnewslist();
    },
    methods:{
        getnewslist(){
            this.$http.get("api/getnewslist").then((result) => {
                // console.log(result);
                if(result.data.status === 0){
                    // 获取成功
                    this.newslist = result.data.message;
                }else{
                    // 获取失败
                    Toast("获取新闻失败");
                }
            });
        }
    }
}
</script>

<style lang="scss" scoped>
.mui-table-view{
    li{
        div.newslist_tit{
            display: flex;
            -webkit-display:flex;
            -moz-webkit-display:flex;
            justify-content: space-between;
            align-items: center;
            h3{
                font-size: 14px;
                color: #333;
                width: 76%;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
            }
            span{
                font-size: 12px;
                color: #26a2ff;
            }            
        }
        p{
            font-size: 12px;
        }
    }
}
</style>